\hypertarget{class_zebulon_1_1_m_c_u_1_1_interface}{
\section{Zebulon::MCU::Interface Class Reference}
\label{class_zebulon_1_1_m_c_u_1_1_interface}\index{Zebulon::MCU::Interface@{Zebulon::MCU::Interface}}
}


\hyperlink{class_zebulon_1_1_m_c_u_1_1_interface}{Interface} class for the Underwater Vehicle to the MCU motor \hyperlink{structcontrol}{control}.  


{\ttfamily \#include $<$interface.h$>$}\subsection*{Classes}
\begin{DoxyCompactItemize}
\item 
class \hyperlink{class_zebulon_1_1_m_c_u_1_1_interface_1_1_callback}{Callback}
\end{DoxyCompactItemize}
\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\hypertarget{class_zebulon_1_1_m_c_u_1_1_interface_a4406d74c75bdfe150bf72be1f1cda8b1}{
\hyperlink{class_zebulon_1_1_m_c_u_1_1_interface_a4406d74c75bdfe150bf72be1f1cda8b1}{Interface} ()}
\label{class_zebulon_1_1_m_c_u_1_1_interface_a4406d74c75bdfe150bf72be1f1cda8b1}

\begin{DoxyCompactList}\small\item\em Constructor. \item\end{DoxyCompactList}\item 
\hypertarget{class_zebulon_1_1_m_c_u_1_1_interface_a19179888f29f18f1be54a3dfe98f68c0}{
\hyperlink{class_zebulon_1_1_m_c_u_1_1_interface_a19179888f29f18f1be54a3dfe98f68c0}{$\sim$Interface} ()}
\label{class_zebulon_1_1_m_c_u_1_1_interface_a19179888f29f18f1be54a3dfe98f68c0}

\begin{DoxyCompactList}\small\item\em Destructor. \item\end{DoxyCompactList}\item 
bool \hyperlink{class_zebulon_1_1_m_c_u_1_1_interface_a2626a924067e62a26c6729075c84b116}{Initialize} (const std::string \&port, const unsigned short baud, const bool tryOtherBauds=true)
\begin{DoxyCompactList}\small\item\em Establishes a connection to the device by searching different BAUDS on a port. \item\end{DoxyCompactList}\item 
\hypertarget{class_zebulon_1_1_m_c_u_1_1_interface_a12ac9d9b3a2beb2f1b7a755a84217f43}{
void \hyperlink{class_zebulon_1_1_m_c_u_1_1_interface_a12ac9d9b3a2beb2f1b7a755a84217f43}{Shutdown} ()}
\label{class_zebulon_1_1_m_c_u_1_1_interface_a12ac9d9b3a2beb2f1b7a755a84217f43}

\begin{DoxyCompactList}\small\item\em Shutsdown the interface. \item\end{DoxyCompactList}\item 
bool \hyperlink{class_zebulon_1_1_m_c_u_1_1_interface_a4383a5e77edad2148f762ad1f15fe143}{Send} (const \hyperlink{class_zebulon_1_1_m_c_u_1_1_message}{Message} $\ast$message)
\begin{DoxyCompactList}\small\item\em Sends the message over the serial port to the device. \item\end{DoxyCompactList}\item 
bool \hyperlink{class_zebulon_1_1_m_c_u_1_1_interface_a6c7fa0e2ac91f9d91fd51ec6912578e1}{RegisterCallback} (const \hyperlink{class_zebulon_1_1_m_c_u_1_1_message_a31e1f57be3ba6baa7fd656b776caea8f}{Message::Code} type, \hyperlink{class_zebulon_1_1_m_c_u_1_1_interface_1_1_callback}{Callback} $\ast$cb)
\begin{DoxyCompactList}\small\item\em Use this method to register a callback to be run whenever a specific type of message is received. \item\end{DoxyCompactList}\item 
void \hyperlink{class_zebulon_1_1_m_c_u_1_1_interface_a459d99d815328572c1d3cf3dc3740c8d}{RemoveCallback} (const \hyperlink{class_zebulon_1_1_m_c_u_1_1_message_a31e1f57be3ba6baa7fd656b776caea8f}{Message::Code} type, \hyperlink{class_zebulon_1_1_m_c_u_1_1_interface_1_1_callback}{Callback} $\ast$cb)
\begin{DoxyCompactList}\small\item\em Use this method to unregister a callback. \item\end{DoxyCompactList}\item 
\hypertarget{class_zebulon_1_1_m_c_u_1_1_interface_a17bfd769f78fabf29b2a2c56598f3bb9}{
void \hyperlink{class_zebulon_1_1_m_c_u_1_1_interface_a17bfd769f78fabf29b2a2c56598f3bb9}{ClearCallback} ()}
\label{class_zebulon_1_1_m_c_u_1_1_interface_a17bfd769f78fabf29b2a2c56598f3bb9}

\begin{DoxyCompactList}\small\item\em Clears all registered callbacks. \item\end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Static Public Member Functions}
\begin{DoxyCompactItemize}
\item 
static \hyperlink{class_zebulon_1_1_m_c_u_1_1_message}{Message} $\ast$ \hyperlink{class_zebulon_1_1_m_c_u_1_1_interface_adeb5a1b1b3487814aab0ac74dda056ef}{CreateMessage} (const \hyperlink{class_zebulon_1_1_m_c_u_1_1_message_a31e1f57be3ba6baa7fd656b776caea8f}{Message::Code} type)
\begin{DoxyCompactList}\small\item\em This method is used to create an instance of any type of MCU message. \item\end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Static Protected Member Functions}
\begin{DoxyCompactItemize}
\item 
static void \hyperlink{class_zebulon_1_1_m_c_u_1_1_interface_a4bde57d9de78de0f8781fac4262f0c69}{MCUThread} (void $\ast$arg)
\begin{DoxyCompactList}\small\item\em Thread used to receive data from sensor. \item\end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Protected Attributes}
\begin{DoxyCompactItemize}
\item 
\hypertarget{class_zebulon_1_1_m_c_u_1_1_interface_a65957805d2b03fe83ff847f75c3c3854}{
CxUtils::Thread \hyperlink{class_zebulon_1_1_m_c_u_1_1_interface_a65957805d2b03fe83ff847f75c3c3854}{mMCUThread}}
\label{class_zebulon_1_1_m_c_u_1_1_interface_a65957805d2b03fe83ff847f75c3c3854}

\begin{DoxyCompactList}\small\item\em Manages/creates thread. \item\end{DoxyCompactList}\item 
\hypertarget{class_zebulon_1_1_m_c_u_1_1_interface_a27b1317f2346f14170d13b5be0d88b3a}{
CxUtils::Mutex \hyperlink{class_zebulon_1_1_m_c_u_1_1_interface_a27b1317f2346f14170d13b5be0d88b3a}{mMCUMutex}}
\label{class_zebulon_1_1_m_c_u_1_1_interface_a27b1317f2346f14170d13b5be0d88b3a}

\begin{DoxyCompactList}\small\item\em Mutex for thread protection of data members. \item\end{DoxyCompactList}\item 
\hypertarget{class_zebulon_1_1_m_c_u_1_1_interface_a804abca748671063f79798c23f67c46b}{
CxUtils::Serial \hyperlink{class_zebulon_1_1_m_c_u_1_1_interface_a804abca748671063f79798c23f67c46b}{mSerial}}
\label{class_zebulon_1_1_m_c_u_1_1_interface_a804abca748671063f79798c23f67c46b}

\begin{DoxyCompactList}\small\item\em Connection to serial port. \item\end{DoxyCompactList}\item 
\hypertarget{class_zebulon_1_1_m_c_u_1_1_interface_a2ce0c66089f891d8c736031a211fe22a}{
\hyperlink{class_zebulon_1_1_m_c_u_1_1_message_a2f23f19457ca7e2a24a9035aeb0e03cd}{Message::List} \hyperlink{class_zebulon_1_1_m_c_u_1_1_interface_a2ce0c66089f891d8c736031a211fe22a}{mMessageQueue}}
\label{class_zebulon_1_1_m_c_u_1_1_interface_a2ce0c66089f891d8c736031a211fe22a}

\begin{DoxyCompactList}\small\item\em Queue of received MCU messages. \item\end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Detailed Description}
\hyperlink{class_zebulon_1_1_m_c_u_1_1_interface}{Interface} class for the Underwater Vehicle to the MCU motor \hyperlink{structcontrol}{control}. 

\subsection{Member Function Documentation}
\hypertarget{class_zebulon_1_1_m_c_u_1_1_interface_adeb5a1b1b3487814aab0ac74dda056ef}{
\index{Zebulon::MCU::Interface@{Zebulon::MCU::Interface}!CreateMessage@{CreateMessage}}
\index{CreateMessage@{CreateMessage}!Zebulon::MCU::Interface@{Zebulon::MCU::Interface}}
\subsubsection[{CreateMessage}]{\setlength{\rightskip}{0pt plus 5cm}{\bf Message} $\ast$ Interface::CreateMessage (const {\bf Message::Code} {\em type})\hspace{0.3cm}{\ttfamily  \mbox{[}static\mbox{]}}}}
\label{class_zebulon_1_1_m_c_u_1_1_interface_adeb5a1b1b3487814aab0ac74dda056ef}


This method is used to create an instance of any type of MCU message. 
\begin{DoxyParams}{Parameters}
\item[\mbox{$\leftarrow$} {\em type}]The type of message to create.\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Pointer to created message (you must delete it), NULL if type is unknown. 
\end{DoxyReturn}
\hypertarget{class_zebulon_1_1_m_c_u_1_1_interface_a2626a924067e62a26c6729075c84b116}{
\index{Zebulon::MCU::Interface@{Zebulon::MCU::Interface}!Initialize@{Initialize}}
\index{Initialize@{Initialize}!Zebulon::MCU::Interface@{Zebulon::MCU::Interface}}
\subsubsection[{Initialize}]{\setlength{\rightskip}{0pt plus 5cm}bool Interface::Initialize (const std::string \& {\em port}, \/  const unsigned short {\em baud}, \/  const bool {\em tryOtherBauds} = {\ttfamily true})}}
\label{class_zebulon_1_1_m_c_u_1_1_interface_a2626a924067e62a26c6729075c84b116}


Establishes a connection to the device by searching different BAUDS on a port. 
\begin{DoxyParams}{Parameters}
\item[\mbox{$\leftarrow$} {\em port}]The port name to connect on. \item[\mbox{$\leftarrow$} {\em baud}]The initial/first BAUD to try.\end{DoxyParams}
\begin{DoxyReturn}{Returns}
True if connection established, otherwise false. 
\end{DoxyReturn}
\hypertarget{class_zebulon_1_1_m_c_u_1_1_interface_a4bde57d9de78de0f8781fac4262f0c69}{
\index{Zebulon::MCU::Interface@{Zebulon::MCU::Interface}!MCUThread@{MCUThread}}
\index{MCUThread@{MCUThread}!Zebulon::MCU::Interface@{Zebulon::MCU::Interface}}
\subsubsection[{MCUThread}]{\setlength{\rightskip}{0pt plus 5cm}void Interface::MCUThread (void $\ast$ {\em arg})\hspace{0.3cm}{\ttfamily  \mbox{[}static, protected\mbox{]}}}}
\label{class_zebulon_1_1_m_c_u_1_1_interface_a4bde57d9de78de0f8781fac4262f0c69}


Thread used to receive data from sensor. Runs a thread which continuously receives and parsed data from serial port. \hypertarget{class_zebulon_1_1_m_c_u_1_1_interface_a6c7fa0e2ac91f9d91fd51ec6912578e1}{
\index{Zebulon::MCU::Interface@{Zebulon::MCU::Interface}!RegisterCallback@{RegisterCallback}}
\index{RegisterCallback@{RegisterCallback}!Zebulon::MCU::Interface@{Zebulon::MCU::Interface}}
\subsubsection[{RegisterCallback}]{\setlength{\rightskip}{0pt plus 5cm}bool Interface::RegisterCallback (const {\bf Message::Code} {\em type}, \/  {\bf Callback} $\ast$ {\em cb})}}
\label{class_zebulon_1_1_m_c_u_1_1_interface_a6c7fa0e2ac91f9d91fd51ec6912578e1}


Use this method to register a callback to be run whenever a specific type of message is received. 
\begin{DoxyParams}{Parameters}
\item[\mbox{$\leftarrow$} {\em type}]The type of message to subscribe to. \item[\mbox{$\leftarrow$} {\em cb}]The callback to be run when the message is received.\end{DoxyParams}
\begin{DoxyReturn}{Returns}
True on success, false on failure. 
\end{DoxyReturn}
\hypertarget{class_zebulon_1_1_m_c_u_1_1_interface_a459d99d815328572c1d3cf3dc3740c8d}{
\index{Zebulon::MCU::Interface@{Zebulon::MCU::Interface}!RemoveCallback@{RemoveCallback}}
\index{RemoveCallback@{RemoveCallback}!Zebulon::MCU::Interface@{Zebulon::MCU::Interface}}
\subsubsection[{RemoveCallback}]{\setlength{\rightskip}{0pt plus 5cm}void Interface::RemoveCallback (const {\bf Message::Code} {\em type}, \/  {\bf Callback} $\ast$ {\em cb})}}
\label{class_zebulon_1_1_m_c_u_1_1_interface_a459d99d815328572c1d3cf3dc3740c8d}


Use this method to unregister a callback. 
\begin{DoxyParams}{Parameters}
\item[\mbox{$\leftarrow$} {\em type}]The type of message to subscribe to. \item[\mbox{$\leftarrow$} {\em cb}]The callback to be run when the message is received. \end{DoxyParams}
\hypertarget{class_zebulon_1_1_m_c_u_1_1_interface_a4383a5e77edad2148f762ad1f15fe143}{
\index{Zebulon::MCU::Interface@{Zebulon::MCU::Interface}!Send@{Send}}
\index{Send@{Send}!Zebulon::MCU::Interface@{Zebulon::MCU::Interface}}
\subsubsection[{Send}]{\setlength{\rightskip}{0pt plus 5cm}bool Interface::Send (const {\bf Message} $\ast$ {\em message})}}
\label{class_zebulon_1_1_m_c_u_1_1_interface_a4383a5e77edad2148f762ad1f15fe143}


Sends the message over the serial port to the device. 
\begin{DoxyParams}{Parameters}
\item[\mbox{$\leftarrow$} {\em message}]Pointer to message structure to transmit.\end{DoxyParams}
\begin{DoxyReturn}{Returns}
True on success, false on failure. 
\end{DoxyReturn}


The documentation for this class was generated from the following files:\begin{DoxyCompactItemize}
\item 
C:/Users/Matt/Documents/School/Robotics/zebulon/v2/mcu/include/mcu/interface.h\item 
C:/Users/Matt/Documents/School/Robotics/zebulon/v2/mcu/src/mcu/interface.cpp\end{DoxyCompactItemize}
